.\" Copyright (c) 1983, 1991, 1993
.\"	The Regents of the University of California.  All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\"    must display the following acknowledgement:
.\"	This product includes software developed by the University of
.\"	California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\"    may be used to endorse or promote products derived from this software
.\"    without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD: net/sctp_connectx.3 202176 2010-01-12 21:45:03Z brueffer $
.\"
.Dd June 19, 2007
.Dt SCTP_CONNECTX 3
.Os
.Sh NAME
.Nm sctp_connectx
.Nd connect an SCTP socket with multiple destination addresses.
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
.In sys/types.h
.In sys/socket.h
.In netinet/sctp.h
.Ft int
.Fn sctp_connectx "int sd" "struct sockaddr *addrs" "int addrcnt" "sctp_assoc_t *id"
.Sh DESCRIPTION
The
.Fn sctp_connectx
call attempts to initiate an association to a peer SCTP
endpoint.
The call operates similarly to
.Fn connect
but it also provides the ability to specify multiple destination
addresses for the peer.
This allows a fault tolerant method
of initiating an association.
When one of the peers addresses
is unreachable, the subsequent listed addresses will also be used
to set up the association with the peer. 
.Pp
The user also needs to consider that any address listed in an 
.Fn sctp_connectx
call is also considered "confirmed".
A confirmed address is one in
which the SCTP transport will trust is a part of the association
and it will not send a confirmation heartbeat to it with
a random nonce. 
.Pp
If the peer SCTP stack does not list one or more of
the provided addresses in its response message then 
the extra addresses sent in the
.Fn sctp_connectx
call will be silently discarded from the association.
On
successful completion the provided
.Fa id
will be
filled in with the association identification of the newly
forming association.
.Sh RETURN VALUES
The call returns 0 on success and -1 upon failure.
.Sh ERRORS
The
.Fn sctp_connectx
function can return the following errors:
.Bl -tag -width Er
.It Bq Er EINVAL
An address listed has an invalid family or no
addresses were provided.
.It Bq Er E2BIG
The size of the address list exceeds the amount of
data provided.
.It Bq Er EBADF
The argument
.Fa s
is not a valid descriptor.
.It Bq Er ENOTSOCK
The argument
.Fa s
is not a socket.
.El
.Sh SEE ALSO
.Xr connect 2 ,
.Xr sctp 4
